package com.itheima.demo3;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        //定义插口对象
        Socket socket = new Socket("127.0.0.1", 10086);
        Scanner sc = new Scanner(System.in);

        //定义写入对象流
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

        //定义读取对象流
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        System.out.println("请输入一段文本");
        //循环输入数据
        String next;
        while (!(next= sc.next()).equals("over")) {
            //往服务端传输数据
            //写入数据
            bufferedWriter.write(next);
            bufferedWriter.newLine();
            bufferedWriter.flush();
            System.out.println("请输入一段文本");
        }

        System.out.println("结束访问");

        socket.close();
    }
}
